package com.ruoyi.web.controller.emergency;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.emergency.domain.EmergencyPj;
import com.ruoyi.emergency.service.IEmergencyPjService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 事故后评价Controller
 * 
 * @author ruoyi
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/control/emergencyPj")
public class EmergencyPjController extends BaseController
{
    @Autowired
    private IEmergencyPjService emergencyPjService;

    /**
     * 查询事故后评价列表
     */
    @PreAuthorize("@ss.hasPermi('control:emergencyPj:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmergencyPj emergencyPj)
    {
        startPage();
        List<EmergencyPj> list = emergencyPjService.selectEmergencyPjList(emergencyPj);
        return getDataTable(list);
    }

    /**
     * 导出事故后评价列表
     */
    @PreAuthorize("@ss.hasPermi('control:emergencyPj:export')")
    @Log(title = "事故后评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmergencyPj emergencyPj)
    {
        List<EmergencyPj> list = emergencyPjService.selectEmergencyPjList(emergencyPj);
        ExcelUtil<EmergencyPj> util = new ExcelUtil<EmergencyPj>(EmergencyPj.class);
        util.exportExcel(response, list, "事故后评价数据");
    }

    /**
     * 获取事故后评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:emergencyPj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(emergencyPjService.selectEmergencyPjById(id));
    }

    /**
     * 新增事故后评价
     */
    @PreAuthorize("@ss.hasPermi('control:emergencyPj:add')")
    @Log(title = "事故后评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmergencyPj emergencyPj)
    {
        return toAjax(emergencyPjService.insertEmergencyPj(emergencyPj));
    }

    /**
     * 修改事故后评价
     */
    @PreAuthorize("@ss.hasPermi('control:emergencyPj:edit')")
    @Log(title = "事故后评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmergencyPj emergencyPj)
    {
        return toAjax(emergencyPjService.updateEmergencyPj(emergencyPj));
    }

    /**
     * 删除事故后评价
     */
    @PreAuthorize("@ss.hasPermi('control:emergencyPj:remove')")
    @Log(title = "事故后评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(emergencyPjService.deleteEmergencyPjByIds(ids));
    }
}
